package com.yycx.module.bus.provider.handler.haiying.salemanbalance;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.base.utils.FlymeUtils;
import com.yycx.common.mybatis.interceptor.PageInterceptor;
import com.yycx.common.mybatis.model.PageParams;
import com.yycx.common.mybatis.query.CriteriaQuery;
import com.yycx.common.security.OpenHelper;
import com.yycx.common.security.OpenUser;
import com.yycx.module.bus.client.entity.hy.BusPaymentOrder;
import com.yycx.module.bus.client.entity.hy.HyOrder;
import org.springframework.stereotype.Component;

/**
 * 认款使用订单明细
 *
 * @author zyf
 */
@Component
public class SaleBalanceDiKouDetailsPageListHandler implements PageInterceptor<BusPaymentOrder> {


    @Override
    public void prepare(CriteriaQuery<BusPaymentOrder> cq, PageParams pageParams, EntityMap params) {
        OpenUser openUser = OpenHelper.getUser();
        Long saleManBalanceId = params.getLong("saleManBalanceId");
        Long companyId = params.getLong("companyId", openUser.getCompanyId());
        String beginDate = params.get("beginDate");
        String endDate = params.get("endDate");
        cq.addSelect(HyOrder.class, "orderNo", "sendDate", "sendType", "saleManName");
        cq.eq(true, "bhd.saleManBalanceId", saleManBalanceId);
        cq.eq(true, "bhd.companyId", companyId);
        cq.ge(FlymeUtils.isNotEmpty(beginDate), "payDate", beginDate);
        cq.le(FlymeUtils.isNotEmpty(endDate), "payDate", endDate);
        cq.orderByDesc("bhd.createTime");
    }
}
